import java.util.*;

/**
 * @author LKQ
 * @date 2022/3/23 20:07
 * @description 模拟
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] time = {1, 2};
        solution.findPoisonedDuration(time, 2);
    }
    public int findPoisonedDuration(int[] timeSeries, int duration) {
        int ans = 0;
        // 中毒结束时间
        int expired = 0;
        for (int time : timeSeries) {
            if (time >= expired) {
                ans += duration;
            } else {
                ans += time + duration - expired;
            }
            expired = time + duration;
        }
        return ans;
    }
}
